package main;

import java.awt.BorderLayout;

import javax.swing.JFrame;

public class Main {

	public static void main(String[] args) {
		MainPanel mainPanel = new MainPanel();
		ScorePanel scorePanel = new ScorePanel();
		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setTitle("贪吃蛇");
		frame.setResizable(false);
		frame.add(mainPanel);
		frame.add(scorePanel, BorderLayout.NORTH);
		frame.pack();
		frame.setLocationRelativeTo(null);
		mainPanel.setFocusable(true);
		frame.setVisible(true);
		mainPanel.requestFocus();
		while (true) {
			scorePanel.setScore(mainPanel.getScore());
			frame.repaint();
			try {
				Thread.sleep(150);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
